home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / sw / sw_comm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.3 KB  |  74 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #ifndef SW_COMM_H
  18. #define    SW_COMM_H
  19.  
  20. #include "comm.h"
  21.  
  22. class SwServer {
  23.   public:
  24.     enum        { NotConnected, Connected, NoSuchServer,
  25.               ConnectionBroken, OtherError };
  26.  
  27.             SwServer(const char* serverName);
  28.             SwServer(NetId serverId);
  29.             ~SwServer();
  30.  
  31.     int            open(const ShipObject*);// open connection to server
  32.     void        close();        // close connection to server
  33.     int            state() const;        // TRUE if open
  34.  
  35.     NetId        serverId() const;    // server id
  36.     NetId        hostId() const;        // my host id
  37.  
  38.     void        send(const SwAliveMessage&);
  39.     void        send(const SwHitMessage&);
  40.     void        send(const SwKilledMessage&);
  41.     void        send(const SwGrabFlagMessage&);
  42.     void        send(const SwDropFlagMessage&);
  43.     void        send(const SwCaptureFlagMessage&);
  44.     void        send(const char* message);
  45.     void        send(const char* message, NetId aboutWhom);
  46.     void        send(const char* message, Team aboutWhichTeam);
  47.     ServerMessageType    receive(int block = 0);    // return message type
  48.     ServerMessageType    type() const;        // get message type
  49.     const SwAnyMessage*    get() const;        // get actual message
  50.  
  51.   private:
  52.     void        init();
  53.     void        getWorld();
  54.     void        send();
  55.  
  56.   private:
  57.     int            status;            // connection status
  58.     int            fd;            // connection file descriptor
  59.     NetId        serverNetId;
  60.     NetId        hostNetId;
  61.     ServerPacket    messageIn;
  62.     ServerPacket    messageOut;
  63.     fd_set        read_set;
  64. };
  65.  
  66. void            handleServerMessages();
  67. int            openBroadcast(int port);    // TRUE if success
  68. void            closeBroadcast();
  69. int            sendBroadcast(const ShipInfo&);
  70. int            recvBroadcast(ShipInfo&);
  71. void            handleBroadcastMessages();
  72.  
  73. #endif
  74.